<div id="nav-right">
    <div class="nav-divider">&nbsp;</div>
    <div class="showhide-account"><?php echo $this->Html->image('user.png',array('style'=>'margin:-5px;width:24px','class'=>'info-tooltip','title'=>'You login as '.$current_user['username'])) ?></div>
    <div class="nav-divider">&nbsp;</div>
    <div class="showhide-account"><?php echo $this->Html->link('Settings',array('controller'=>'users','action'=>'setting','admin'=>true),array('style'=>'color:#5E350D')) ?></div>
    <div class="nav-divider">&nbsp;</div>
    <?php echo $this->Html->link($this->Html->image('../images/logout.png', array('width' => '64', 'height' => '14', 'alt' => '')),array('controller'=>'users','action'=>'logout','superadmin'=>false,'admin'=>false),array('id'=>'logout','escape' => false)) ?>
    <div class="clear">&nbsp;</div>
</div>
		
<?php echo $this->Html->css('admin/jqueryslidemenu'); ?>
<?php echo $this->Html->script('admin/jqueryslidemenu'); ?>
<div id="myslidemenu" class="jqueryslidemenu">
    <ul>
        <li id="userMenu" class="users-index">
            <?php echo $this->Html->link('<b>Users</b>',array('controller'=>'users','action'=>'index','admin'=>true),array('escape'=>false)) ?>
        </li>
        <li id="customerMenu" class="">
            <?php echo $this->Html->link('<b>Customers</b>',array('controller'=>'customers','action'=>'index','admin'=>true),array('escape'=>false)) ?>
            <ul>
                <li class="customers-index">
                    <?php echo $this->Html->link('<b>Interest List</b>',array('controller'=>'interests','action'=>'index','admin'=>true),array('escape'=>false)) ?>
                </li>
                <li class="customer_types-index">
                    <?php echo $this->Html->link('<b>Customer Types</b>',array('controller'=>'customer_types','action'=>'index','admin'=>true),array('escape'=>false)) ?>
                </li>
                <li class="shopper_groups-index">
                    <?php echo $this->Html->link('<b>Shopper Groups</b>',array('controller'=>'shopper_groups','action'=>'index','admin'=>true),array('escape'=>false)) ?>
                </li>
            </ul>
        </li>
        <li id="cashierMenu" class="cashiers-index">
            <?php echo $this->Html->link('<b>Cashiers</b>',array('controller'=>'cashiers','action'=>'index','admin'=>true),array('escape'=>false)) ?>
        </li>
        <li id="content-Menu" class="users-contents">
            <?php echo $this->Html->link('<b>Contents</b>',array('controller'=>'users','action'=>'content','admin'=>true),array('escape'=>false)) ?>
        </li>
        <li id="queryMenu" class="">
            <?php echo $this->Html->link('<b>Support</b>','#',array('onClick'=>'return false','escape'=>false)) ?>
            <ul>
                <li id="ticketMenu" class="ticket-index">
                    <?php echo $this->Html->link('<b>Tickets</b>',array('controller'=>'tickets', 'action'=>'index', 'admin'=>true),array('escape'=>false)) ?>
                </li>
                <li id="helpMenu" class="help-index">
                    <?php echo $this->Html->link('<b>Help Desk</b>',array('controller'=>'tickets', 'action'=>'enquiry_list', 'admin'=>true),array('escape'=>false)) ?>
                </li>
            </ul>
        </li>
        <li id="eventMenu" class="events-index">
            <?php echo $this->Html->link('<b>Events</b>',array('controller'=>'calendars', 'action'=>'index', 'admin'=>true),array('escape'=>false)) ?>
        </li>
        <!--<li id="templateMenu" class="templates-index">
            <?php echo $this->Html->link('<b>Templates</b>',array('controller'=>'templates','action'=>'index','admin'=>true),array('escape'=>false)) ?>
        </li>-->
        <li id="messagesMenu" class="messages-index">
            <?php echo $this->Html->link('<b>Notifications</b>',array('controller'=>'messages', 'action'=>'index', 'admin'=>true),array('escape'=>false)) ?>
        </li>
        <li id="voucherMenu" class="vouchers-index">
            <?php echo $this->Html->link('<b>Vouchers</b>',array('controller'=>'vouchers', 'action'=>'index', 'admin'=>true),array('escape'=>false)) ?>
        </li>
        <li id="surveyMenu" class="surveys-index">
            <?php echo $this->Html->link('<b>Surveys</b>',array('controller'=>'surveys', 'action'=>'index', 'admin'=>true),array('escape'=>false)) ?>
        </li>
        <li id="giftsMenu" class="gifts-index">
            <?php echo $this->Html->link('<b>Gift Cards</b>',array('controller'=>'gifts', 'action'=>'index', 'admin'=>true),array('escape'=>false)) ?>
        </li>
        <li id="reportsMenu" class="reports-index">
            <?php echo $this->Html->link('<b>Reports</b>',array('controller'=>'reports', 'action'=>'index', 'admin'=>true),array('escape'=>false)) ?>
        </li>
        <li id="slidersMenu" class="users-sliders">
            <?php echo $this->Html->link('<b>Sliders</b>',array('controller'=>'users', 'action'=>'sliders', 'admin'=>true),array('escape'=>false)) ?>
        </li>
    </ul>
    <div class="clear"></div>
</div>
<script type="text/javascript">
function check_view(menu){
    check = 0;
    if(menu=='sesionMenu'){
        jQuery('#'+menu+' ul li ul li').each(function(){
            if(!jQuery(this).hasClass('hidden')){
                check=1;
            }
        });
    }else{
        jQuery('#'+menu+' ul li').each(function(){
            if(!jQuery(this).hasClass('hidden')){
                check=1;
            }
        });
    }
    if(check==1){
        jQuery('#'+menu).removeClass('hidden');
    }
}
jQuery(document).ready(function(){

    <?php if(isset($user_permissions)){ ?>
        jQuery('#myslidemenu ul li').each(function(){
            jQuery(this).not('.no-hidden').addClass('hidden');
        });

        <?php foreach ($user_permissions as $controller => $actions) {
            //echo $controller;die;
            $controller = str_replace("_controllers", "", $controller);
            $controller = Inflector::tableize($controller);   
            foreach($actions as $action){
            ?>
                jQuery('#myslidemenu ul li.<?php echo $controller.'-'.$action ?>').removeClass('hidden');
        <?php } } ?>
        check_view('customerMenu');
        check_view('sesionMenu');
        check_view('ticketMenu');
        jQuery('#myslidemenu ul li.hidden').each(function(){
            jQuery(this).remove();
        });
    <?php }else{ ?>

    <?php } ?>
}); 
</script>